home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / wsres2 / form1.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1995-05-07  |  21.2 KB  |  752 lines

  1. VERSION 2.00
  2. Begin Form Form1 
  3.    BackColor       =   &H00C0C0C0&
  4.    BorderStyle     =   1  'Fixed Single
  5.    Caption         =   "WSResMon II"
  6.    ClientHeight    =   3180
  7.    ClientLeft      =   1350
  8.    ClientTop       =   2565
  9.    ClientWidth     =   6240
  10.    Height          =   3870
  11.    Icon            =   FORM1.FRX:0000
  12.    Left            =   1290
  13.    LinkTopic       =   "Form1"
  14.    MaxButton       =   0   'False
  15.    ScaleHeight     =   3180
  16.    ScaleWidth      =   6240
  17.    Top             =   1935
  18.    Width           =   6360
  19.    Begin PictureBox Spin1 
  20.       Height          =   255
  21.       Index           =   2
  22.       Left            =   3645
  23.       ScaleHeight     =   225
  24.       ScaleWidth      =   225
  25.       TabIndex        =   17
  26.       Top             =   2135
  27.       Width           =   255
  28.    End
  29.    Begin PictureBox Spin1 
  30.       Height          =   255
  31.       Index           =   1
  32.       Left            =   3645
  33.       ScaleHeight     =   225
  34.       ScaleWidth      =   225
  35.       TabIndex        =   18
  36.       Top             =   1235
  37.       Width           =   255
  38.    End
  39.    Begin PictureBox Spin1 
  40.       Height          =   255
  41.       Index           =   0
  42.       Left            =   3645
  43.       ScaleHeight     =   225
  44.       ScaleWidth      =   225
  45.       TabIndex        =   19
  46.       Top             =   735
  47.       Width           =   255
  48.    End
  49.    Begin Timer Timer1 
  50.       Interval        =   5000
  51.       Left            =   5400
  52.       Top             =   2400
  53.    End
  54.    Begin TextBox Text1 
  55.       BackColor       =   &H00FFFFFF&
  56.       Height          =   285
  57.       Index           =   0
  58.       Left            =   2640
  59.       MaxLength       =   2
  60.       TabIndex        =   2
  61.       Text            =   "Text1"
  62.       Top             =   735
  63.       Width           =   615
  64.    End
  65.    Begin CheckBox Check1 
  66.       BackColor       =   &H00C0C0C0&
  67.       Caption         =   "S&pace On Drive:"
  68.       Height          =   255
  69.       Index           =   2
  70.       Left            =   600
  71.       TabIndex        =   5
  72.       Top             =   1735
  73.       Width           =   1815
  74.    End
  75.    Begin CheckBox Check1 
  76.       BackColor       =   &H00C0C0C0&
  77.       Caption         =   "&Available &Memory:"
  78.       Height          =   255
  79.       Index           =   1
  80.       Left            =   600
  81.       TabIndex        =   3
  82.       Top             =   1235
  83.       Width           =   1935
  84.    End
  85.    Begin CheckBox Check1 
  86.       BackColor       =   &H00C0C0C0&
  87.       Caption         =   "&System Resources:"
  88.       Height          =   255
  89.       Index           =   0
  90.       Left            =   600
  91.       TabIndex        =   1
  92.       Top             =   735
  93.       Width           =   1935
  94.    End
  95.    Begin TextBox Text1 
  96.       BackColor       =   &H00FFFFFF&
  97.       Height          =   285
  98.       Index           =   2
  99.       Left            =   2640
  100.       MaxLength       =   4
  101.       TabIndex        =   7
  102.       Text            =   "0"
  103.       Top             =   2135
  104.       Width           =   615
  105.    End
  106.    Begin ComboBox Combo1 
  107.       BackColor       =   &H00C0C0C0&
  108.       Height          =   300
  109.       Left            =   2640
  110.       TabIndex        =   6
  111.       Text            =   "0"
  112.       Top             =   1735
  113.       Width           =   1265
  114.    End
  115.    Begin TextBox Text1 
  116.       BackColor       =   &H00FFFFFF&
  117.       Height          =   285
  118.       Index           =   1
  119.       Left            =   2640
  120.       MaxLength       =   4
  121.       TabIndex        =   4
  122.       Text            =   "Text1"
  123.       Top             =   1235
  124.       Width           =   615
  125.    End
  126.    Begin CommandButton Command1 
  127.       Caption         =   "Re&boot!"
  128.       Height          =   450
  129.       Index           =   2
  130.       Left            =   4400
  131.       TabIndex        =   10
  132.       Top             =   1800
  133.       Width           =   1700
  134.    End
  135.    Begin CommandButton Command1 
  136.       Caption         =   "E&xit Windows"
  137.       Height          =   450
  138.       Index           =   1
  139.       Left            =   4400
  140.       TabIndex        =   9
  141.       Top             =   1260
  142.       Width           =   1700
  143.    End
  144.    Begin CommandButton Command1 
  145.       Caption         =   "&Restart Windows"
  146.       Height          =   450
  147.       Index           =   0
  148.       Left            =   4400
  149.       TabIndex        =   8
  150.       Top             =   720
  151.       Width           =   1700
  152.    End
  153.    Begin Label Label1 
  154.       AutoSize        =   -1  'True
  155.       BackColor       =   &H00C0C0C0&
  156.       Caption         =   "disk"
  157.       FontBold        =   0   'False
  158.       FontItalic      =   0   'False
  159.       FontName        =   "MS Sans Serif"
  160.       FontSize        =   8.25
  161.       FontStrikethru  =   0   'False
  162.       FontUnderline   =   0   'False
  163.       Height          =   195
  164.       Index           =   2
  165.       Left            =   4800
  166.       TabIndex        =   14
  167.       Top             =   2880
  168.       Width           =   285
  169.    End
  170.    Begin Label Label1 
  171.       AutoSize        =   -1  'True
  172.       BackColor       =   &H00C0C0C0&
  173.       Caption         =   "Label1"
  174.       FontBold        =   0   'False
  175.       FontItalic      =   0   'False
  176.       FontName        =   "MS Sans Serif"
  177.       FontSize        =   8.25
  178.       FontStrikethru  =   0   'False
  179.       FontUnderline   =   0   'False
  180.       Height          =   195
  181.       Index           =   1
  182.       Left            =   3480
  183.       TabIndex        =   16
  184.       Top             =   2880
  185.       Width           =   480
  186.    End
  187.    Begin Label Label2 
  188.       AutoSize        =   -1  'True
  189.       BackStyle       =   0  'Transparent
  190.       Caption         =   "MB"
  191.       Height          =   195
  192.       Index           =   2
  193.       Left            =   3300
  194.       TabIndex        =   13
  195.       Top             =   2185
  196.       Width           =   285
  197.    End
  198.    Begin Label Label2 
  199.       AutoSize        =   -1  'True
  200.       BackStyle       =   0  'Transparent
  201.       Caption         =   "KB"
  202.       Height          =   195
  203.       Index           =   1
  204.       Left            =   3300
  205.       TabIndex        =   12
  206.       Top             =   1285
  207.       Width           =   255
  208.    End
  209.    Begin Label Label2 
  210.       AutoSize        =   -1  'True
  211.       BackStyle       =   0  'Transparent
  212.       Caption         =   "%"
  213.       Height          =   195
  214.       Index           =   0
  215.       Left            =   3435
  216.       TabIndex        =   11
  217.       Top             =   735
  218.       Width           =   150
  219.    End
  220.    Begin Label Label3 
  221.       BackColor       =   &H00C0C0C0&
  222.       BackStyle       =   0  'Transparent
  223.       Caption         =   "&Trigger Alarm At These Levels:"
  224.       Height          =   2205
  225.       Left            =   360
  226.       TabIndex        =   0
  227.       Top             =   360
  228.       Width           =   3855
  229.    End
  230.    Begin Label Label1 
  231.       AutoSize        =   -1  'True
  232.       BackColor       =   &H00C0C0C0&
  233.       Caption         =   "Label1"
  234.       FontBold        =   0   'False
  235.       FontItalic      =   0   'False
  236.       FontName        =   "MS Sans Serif"
  237.       FontSize        =   8.25
  238.       FontStrikethru  =   0   'False
  239.       FontUnderline   =   0   'False
  240.       Height          =   195
  241.       Index           =   0
  242.       Left            =   1800
  243.       TabIndex        =   15
  244.       Top             =   2880
  245.       Width           =   480
  246.    End
  247.    Begin Menu oMenu 
  248.       Caption         =   "&Options"
  249.       Begin Menu oItem 
  250.          Caption         =   "&Check Levels"
  251.          Index           =   0
  252.          Begin Menu tInt 
  253.             Caption         =   "Once Every Second"
  254.             Index           =   0
  255.          End
  256.          Begin Menu tInt 
  257.             Caption         =   "Once Every 5 Seconds"
  258.             Index           =   1
  259.          End
  260.          Begin Menu tInt 
  261.             Caption         =   "Once Every 10 Seconds"
  262.             Index           =   2
  263.          End
  264.          Begin Menu tInt 
  265.             Caption         =   "Once Every 30  Seconds"
  266.             Index           =   3
  267.          End
  268.          Begin Menu tInt 
  269.             Caption         =   "Once Every Minute"
  270.             Index           =   4
  271.          End
  272.       End
  273.       Begin Menu oItem 
  274.          Caption         =   "&Icon Title"
  275.          Index           =   1
  276.          Begin Menu iTitle 
  277.             Caption         =   "Show System Resources"
  278.             Index           =   0
  279.          End
  280.          Begin Menu iTitle 
  281.             Caption         =   "Show Free Memory"
  282.             Index           =   1
  283.          End
  284.          Begin Menu iTitle 
  285.             Caption         =   "Show Free Disk Space"
  286.             Index           =   2
  287.          End
  288.          Begin Menu iTitle 
  289.             Caption         =   "&Cycle Titles"
  290.             Index           =   3
  291.          End
  292.       End
  293.       Begin Menu oItem 
  294.          Caption         =   "&Hide WSResMon icon"
  295.          Index           =   2
  296.       End
  297.       Begin Menu oItem 
  298.          Caption         =   "-"
  299.          Index           =   3
  300.       End
  301.       Begin Menu oItem 
  302.          Caption         =   "&About WSResMon..."
  303.          Index           =   4
  304.       End
  305.       Begin Menu oItem 
  306.          Caption         =   "-"
  307.          Index           =   5
  308.       End
  309.       Begin Menu oItem 
  310.          Caption         =   "E&xit WSResMon"
  311.          Index           =   6
  312.       End
  313.    End
  314. Option Explicit
  315. DefInt A-Z
  316. Dim SkipSave%
  317. Dim l$(2)
  318. Sub Alert (Mess$)
  319. '  * creates an Alert box with an OK button
  320. MsgBox Mess$, 48, App.Title
  321. End Sub
  322. Sub Check1_Click (Index As Integer)
  323. Dim c%
  324. c% = Check1(Index)
  325. Text1(Index).Enabled = c%
  326. Spin1(Index).Enabled = c%
  327. If Index = 2 Then Combo1.Enabled = c%
  328. If Check1(0) + Check1(1) + Check1(2) = 0 Then
  329.     Timer1.Enabled = False
  330.     If Not Timer1.Enabled Then Timer1.Enabled = True
  331. End If
  332. End Sub
  333. Sub Combo1_Click ()
  334. Timer1_Timer
  335. End Sub
  336. Sub Command1_Click (Index As Integer)
  337. Dim a$
  338. Dim x%, ExitCommand%
  339. ExitCommand% = -99
  340. Select Case Index
  341. Case 0   'restart
  342.    If Confirm%("Restart Windows now?") Then ExitCommand% = &H42
  343. Case 1   'exit
  344.    If Confirm%("Exit Windows now?") Then ExitCommand% = &H0
  345. Case 2   'reboot
  346.    If Confirm%("Exit Windows and reboot your PC now?") Then ExitCommand% = &H43
  347. End Select
  348. If ExitCommand% = -99 Then Exit Sub
  349. MousePointer = 11
  350. x% = ExitWindows(ExitCommand%, 0)
  351. End Sub
  352. Function Confirm% (Ask$)
  353. If MsgBox(Ask$, 52, App.Title) = 6 Then Confirm% = True
  354. End Function
  355. Sub Draw3dFrame (f As Form, c As Label)
  356. 'draw label size you want frame -- no autosize
  357. 'label font must be same as form font!
  358. Const White = &HFFFFFF
  359. Const DarkGrey = &H808080
  360. Dim X1%, X2%, Y1%, Y2%, FrameHeight%, FrameWidth%, FrameLeft%, FrameTop%
  361. f.DrawWidth = 1
  362. FrameLeft% = c.Left
  363. FrameTop% = c.Top
  364. FrameHeight% = c.Height
  365. FrameWidth% = c.Width
  366. 'Draw left of label
  367. X1% = FrameLeft% - 60
  368. X2% = FrameLeft% - 180
  369. Y1% = FrameTop% + (f.TextHeight(c.Caption) / 2) - 60
  370. f.ForeColor = DarkGrey
  371. f.Line (X1%, Y1%)-(X2, Y1%)
  372. Y1% = Y1% + 20
  373. f.ForeColor = White
  374. f.Line (X1%, Y1%)-(X2, Y1%)
  375. 'Draw left side
  376. Y2% = Y1% + FrameHeight%
  377. f.ForeColor = DarkGrey
  378. f.Line (X2%, Y1%)-(X2%, Y2%)
  379. X2% = X2% + 20
  380. f.ForeColor = White
  381. f.Line (X2%, Y1%)-(X2%, Y2%)
  382. 'draw bottom
  383. X1% = X2%
  384. X2% = FrameLeft% + FrameWidth%
  385. f.ForeColor = DarkGrey
  386. f.Line (X1%, Y2)-(X2%, Y2%)
  387. Y2% = Y2% + 15
  388. f.ForeColor = White
  389. f.Line (X1%, Y2)-(X2%, Y2%)
  390. 'draw right
  391. Y1% = FrameTop% + (f.TextHeight(c.Caption) / 2) - 60
  392. f.Line -(X2%, Y1%)
  393. f.ForeColor = DarkGrey
  394. X1% = X2% - 20
  395. f.Line (X1%, Y2% - 20)-(X1%, Y1% + 20)
  396. 'draw top to label right
  397. X2% = FrameLeft% + f.TextWidth(c.Caption) + 60
  398. f.Line (X1%, Y1% - 15)-(X2%, Y1% - 15)
  399. f.ForeColor = White
  400. f.Line (X1%, Y1%)-(X2%, Y1%)
  401. End Sub
  402. Sub DrawStatusLine (c As Control)
  403. Const White = &HFFFFFF
  404. Const DarkGrey = &H808080
  405. Dim Top%
  406. Top% = c.Top - 60
  407. DrawWidth = 1
  408. ForeColor = White
  409. Line (0, Top%)-(Width, Top%)
  410. ForeColor = DarkGrey
  411. Line (0, Top% - 15)-(Width, Top% - 15)
  412. End Sub
  413. Sub Form_Load ()
  414. Dim i%, a%, w&
  415. If App.PrevInstance Then
  416.    a% = FindPrevInstance%("WSResMon")
  417.    If a% > 0 Then w& = ShowWindow(a%, SW_SHOWNORMAL)
  418.    SkipSave% = True
  419.    End
  420. End If
  421. Ini$ = "WSRESMON.INI"
  422. For i% = 2 To 25
  423.    If GetDriveType%(i%) <> 0 Then Combo1.AddItem Chr$(65 + i%) + ":"
  424. CenterForm Me
  425. CRLF$ = Chr$(13) + Chr$(10)
  426. i% = Height - 860
  427. Label1(0).Move Label3.Left - 180, i%
  428. Label1(1).Top = i%
  429. Label1(2).Top = i%
  430. For i% = 0 To 2
  431.    Check1(i) = 1
  432.    Label2(i).Move Text1(i).Left + Text1(i).Width + 30
  433. GetSettings
  434. Timer1_Timer
  435. End Sub
  436. Sub Form_Paint ()
  437. Draw3dFrame Me, Label3
  438. DrawStatusLine Label1(0) 'Label5
  439. End Sub
  440. Sub Form_QueryUnload (Cancel As Integer, UnloadMode As Integer)
  441. If SkipSave% = False Then
  442.     Dim x%, Y%, i%, d#, m&
  443.     'store icon title setting
  444.     For i% = 0 To 3
  445.         If iTitle(i).Checked Then Y% = i%
  446.     Next
  447.     x% = WriteIni%("IconTitle", Str$(Y%))
  448.     'store interval setting
  449.     For i% = 0 To 4
  450.         If tInt(i%).Checked Then Y% = i%
  451.     Next
  452.     x% = WriteIni%("Interval", Str$(Y%))
  453.     Y% = oItem(2).Checked
  454.     x% = WriteIni%("HideIcon", Str$(Y%))
  455.     Y% = Val(Text1(0))
  456.     x% = WriteIni%("ResourceLevel", Str$(Y%))
  457.     m& = Val(Text1(1))
  458.     x% = WriteIni%("MemoryLevel", Str$(m&))
  459.     Y% = Combo1.ListIndex
  460.     x% = WriteIni%("Drive", Str$(Y%))
  461.     d# = Val(Text1(2))
  462.     x% = WriteIni%("DiskSpaceLevel", Str$(d#))
  463.     For Y% = 0 To 2
  464.         x% = WriteIni%("Checkbox" + Trim$(Str$(Y%)), Str$(Check1(Y%)))
  465.     Next
  466.     x% = WriteIni%("Windowstate", Str$(Form1.WindowState))
  467.     On Error GoTo 0
  468.     'now get restored window pos
  469.     Dim WinPlace As WindowPlacement
  470.     WinPlace.Length = 22
  471.     x% = GetWindowPlacement%(Form1.hWnd, WinPlace) 'get current placement
  472.     x% = WriteIni%("PosLeft", Str$(WinPlace.rcNormalPosition.Left * Screen.TwipsPerPixelX))
  473.     x% = WriteIni%("PosTop", Str$(WinPlace.rcNormalPosition.Top * Screen.TwipsPerPixelY))
  474. End If
  475. End Sub
  476. Sub Form_Resize ()
  477. If WindowState = 1 Then
  478.    Timer1_Timer
  479.    If oItem(2).Checked Then
  480.       Dim x%
  481.       x% = FindWindow("ThunderRTMain", 0&)
  482.       If x% Then x% = ShowWindow(x%, 1)
  483.       Visible = False
  484.    End If
  485.    Caption = "WSResMon II"
  486.    Visible = True
  487. End If
  488. 'Dim a$
  489. 'a$ = GetRestorePos$()
  490. 'Debug.Print a$
  491. End Sub
  492. Sub Form_Unload (Cancel As Integer)
  493. End Sub
  494. Sub GetSettings ()
  495. On Error Resume Next
  496. Dim s$
  497. Dim Y%
  498. s$ = GetIni$("ResourceLevel")
  499. If s$ = "" Then 'no ini, so set defaults
  500.     Left = (Screen.Width - Width) / 2
  501.     Top = (Screen.Height - Height) / 2
  502.     WindowState = 0
  503.     iTitle(0).Checked = True
  504.     Combo1.ListIndex = 0
  505.     tInt(1).Checked = True
  506.     Text1(0) = "20"
  507.     Text1(1) = "100"
  508.     Text1(2) = "1.5"
  509.     For Y% = 0 To 2
  510.         Check1(Y%) = 1
  511.     Next
  512.     Exit Sub
  513. End If
  514. 'otherwise, read ini settings
  515. Form1.Move Val(GetIni$("PosLeft")), Val(GetIni$("PosTop"))
  516. Form1.WindowState = Val(GetIni$("Windowstate"))
  517. iTitle_Click Val(GetIni$("IconTitle"))
  518. tInt_Click Val(GetIni$("Interval"))
  519. If Val(GetIni$("HideIcon")) Then oItem_click 2
  520. Text1(0) = GetIni$("ResourceLevel")
  521. Text1(1) = GetIni$("MemoryLevel")
  522. Combo1.ListIndex = Val(GetIni$("Drive"))
  523. Text1(2) = GetIni$("DiskSpaceLevel")
  524. For Y% = 0 To 2
  525.    Check1(Y%) = Val(GetIni$("Checkbox" + Trim$(Str$(Y%))))
  526. End Sub
  527. Sub HighLightIt (c As TextBox)
  528.    c.SelStart = 0
  529.    c.SelLength = Len(c.Text)
  530. End Sub
  531. Sub HScroll1_Change ()
  532. 'If HScroll1 > Val(Label1) Then HScroll1 = Val(Label1)
  533. 'Text1(0) = HScroll1
  534. End Sub
  535. Sub iTitle_Click (Index As Integer)
  536. iTitle(0).Checked = False
  537. iTitle(1).Checked = False
  538. iTitle(2).Checked = False
  539. iTitle(3).Checked = False
  540. iTitle(Index).Checked = True
  541. End Sub
  542. Sub oItem_click (Index As Integer)
  543. Dim a$, Y%
  544. Select Case Index
  545. Case 2 'hide icon
  546.    oItem(Index).Checked = Not oItem(Index).Checked
  547. Case 4   'about
  548.    Alert "WSResMon was developed using Visual Basic 3.0 by Paul Bonner for Windows Sources Magazine." + CRLF$ + CRLF$ + "Copyright 
  549.  1994 by Paul Bonner" + CRLF$ + "All Rights Reserved"
  550. Case 6   'Exit
  551.    If Confirm%("Exit WSResMon now?") Then Unload Me
  552. Case Else
  553. End Select
  554. End Sub
  555. Sub PostAlarm (AlarmType%)
  556.    Dim a$, b$
  557.    Beep
  558.    WindowState = 0
  559.    Visible = True
  560.    Select Case AlarmType%
  561.    Case 0
  562.       b$ = "resources have"
  563.    Case 1
  564.       b$ = "memory has"
  565.    Case 2
  566.       b$ = "disk space has"
  567.    End Select
  568.    a$ = "Free " + b$ + " fallen below the specified threshold."
  569.    If AlarmType% <> 2 Then a$ = a$ + CRLF$ + CRLF$ + "You may wish to close one or more applications in order to free some resources, or to exit or restart Windows."
  570.    a$ = a$ + CRLF$ + CRLF$ + "(The alert threshold has been lowered to the current level for this resource.)"
  571.    Alert a$
  572.    Text1(AlarmType%).SetFocus
  573. End Sub
  574. Sub SetScroll (Res%)
  575. Dim FreeRes%, FreeRAM&, FreeDisk&
  576. FreeRAM& = FreeMem&() / 1024
  577. FreeDisk& = (FreeDriveSpace&(Left$(Combo1, 1)) / 1024) / 1024
  578. FreeRes% = GetFreeRes%(GFSR_SYSTEMRESOURCES)
  579. Dim Y%
  580. On Error Resume Next 'traps error from entering a non-numeric character or blank value
  581. Y% = Val(Text1(Res%))   'y% will be 0 if error occurs
  582. If Y% = 0 Then
  583.     Text1(Res%) = "10"
  584.     Text1(Res%).SelLength = Len(Text1(Res%))
  585.     Text1(Res%).SetFocus
  586. End If
  587. On Error GoTo 0
  588. Select Case Res%
  589. Case 0
  590.    If Y% > FreeRes% Then
  591.       SettingTooHigh "system resource", FreeRes% - 1, Res%
  592.    End If
  593.    Y% = Val(Text1(Res%))
  594.    If Y% < 10 Or Y% > 70 Then
  595.       GoTo BadVal
  596.    Else
  597.       Exit Sub
  598.    End If
  599. Case 1   'mem
  600.    If Y% > FreeRAM& Then
  601.       SettingTooHigh "memory", FreeRAM& - 100, Res%
  602.    End If
  603. Case 2   'disk
  604.    If Y% > FreeDisk& Then
  605.     SettingTooHigh "disk space", FreeDisk& - .1, Res%
  606.    End If
  607. End Select
  608. Exit Sub
  609. BadVal:
  610.    Alert "Threshold value must be between 10 and 70."
  611.    If Y% < 10 Then Text1(0) = "10"
  612.    If Y% > 70 Then Text1(0) = "70"
  613.    Text1(0).SetFocus
  614.    HighLightIt Text1(0)
  615. End Sub
  616. Sub SettingTooHigh (Setting$, NewVal#, Res%)
  617.       Alert "You can't set the " + Setting$ + " threshold above the current free " + Setting$ + " level."
  618.       Text1(Res%) = NewVal#
  619.       HighLightIt Text1(Res%)
  620. End Sub
  621. Sub Spin1_SpinDown (Index As Integer)
  622. Dim Increment#
  623. Select Case Index
  624. Case 0
  625.    Increment# = 5
  626. Case 1
  627.    Increment# = 100
  628. Case 2
  629.    Increment# = .1
  630. End Select
  631. Text1(Index) = Trim$(Str$(Val(Text1(Index) - Increment#)))
  632. SetScroll Index
  633. End Sub
  634. Sub Spin1_SpinUp (Index As Integer)
  635. Dim Increment#
  636. Select Case Index
  637. Case 0
  638.    Increment# = 5
  639. Case 1
  640.    Increment# = 100
  641. Case 2
  642.    Increment# = .1
  643. End Select
  644. On Error Resume Next
  645. Text1(Index) = Trim$(Str$(Val(Text1(Index) + Increment#)))
  646. SetScroll Index
  647. End Sub
  648. Sub Text1_Change (Index As Integer)
  649. If Len(Text1(Index)) < 2 Then Exit Sub
  650. SetScroll Index
  651. End Sub
  652. Sub Text1_GotFocus (Index As Integer)
  653. HighLightIt Text1(Index)
  654. End Sub
  655. Sub Text1_LostFocus (Index As Integer)
  656. SetScroll Index
  657. End Sub
  658. Sub Timer1_Timer ()
  659. Dim a$, FreeRAM&, FreeDisk&, FreeRes%, disp%, w$
  660. If Check1(0) Then FreeRes% = GetFreeRes%(0) 'GetFreeSystemResources%(GFSR_SYSTEMRESOURCES)
  661. If Check1(1) Then FreeRAM& = FreeMem&() / 1024
  662. If Check1(2) Then FreeDisk& = (FreeDriveSpace&(Left$(Combo1, 1)) / 1000) / 1000
  663. Static Counter%
  664. 'update resources on status line
  665. a$ = "System Resources: "
  666. If FreeRes% > 0 Then
  667.     a$ = a$ & FreeRes% & "%"
  668.     a$ = a$ & "n/a"
  669. End If
  670. disp% = 450
  671. If Label1(0) <> a$ Then
  672.    Label1(0) = a$
  673.    Label1(1).Move Label1(0).Left + Label1(0).Width + disp%
  674.    Label1(2).Move Label1(1).Left + Label1(1).Width + disp%
  675. End If
  676. 'update memory on status line
  677. a$ = "Memory: "
  678. 'a$ = "RAM: " & Format$(FreeRAM&, "###,###.0#") & " KB"
  679. If FreeRAM& > 0 Then
  680.     a$ = a$ & Format$(FreeRAM&, "###,###.0#") & " KB"
  681.     a$ = a$ & "n/a"
  682. End If
  683. If Label1(1) <> a$ Then
  684.    Label1(1) = a$
  685.    Label1(2).Move Label1(1).Left + Label1(1).Width + disp%
  686. End If
  687. 'update disk space on status line
  688. a$ = "Disk " & Combo1 + " "
  689. If FreeDisk& > 0 Then
  690.     a$ = a$ & Format$(FreeDisk&, "###,###.0#") & " MB"
  691.     a$ = a$ & "n/a"
  692. End If
  693. If Label1(2) <> a$ Then Label1(2) = a$
  694. If WindowState = 1 Then
  695. 'Check resources
  696. If FreeRes% < Val(Text1(0)) And Check1(0) Then
  697.    PostAlarm 0
  698.    Text1(0) = Trim$(Str$(FreeRes% - 1))
  699.    Exit Sub
  700. End If
  701. 'Check memory
  702. If FreeRAM& < Val(Text1(1)) And Check1(1) Then
  703.    PostAlarm 1
  704.    Text1(1) = Trim$(Str$(FreeRAM& - 100))
  705.    Exit Sub
  706. End If
  707. 'check disk space
  708. If FreeDisk& < Val(Text1(2)) And Check1(2) Then
  709.    PostAlarm 2
  710.    Text1(2) = Format$(Trim$(Str$(FreeDisk& - .1)), "##.#")
  711.    Exit Sub
  712. End If
  713. l$(0) = "Sys. Res:" & FreeRes% & "%"
  714. l$(1) = "RAM: " & Format$(FreeRAM&, "###,###") & " KB"
  715. l$(2) = Combo1 + " " & Format$(FreeDisk&, "###,###") & " MB"
  716. If iTitle(0).Checked Then
  717.     disp% = 0
  718. ElseIf iTitle(1).Checked Then 'iTitle(1).Checked Then
  719.     disp% = 1
  720. ElseIf iTitle(2).Checked Then
  721.     disp% = 2
  722. TryAgain:
  723.     If Timer1.Enabled = False Then Exit Sub
  724.     Counter% = Counter% + 1
  725.     If Counter% = 3 Then Counter% = 0
  726.     If Not Check1(Counter%) > 0 Then GoTo TryAgain
  727.     disp% = Counter%
  728. End If
  729. a$ = App.Title + CRLF$ + l$(disp%)
  730. If Visible And Caption <> a$ Then Caption = a$
  731. End If
  732. End Sub
  733. Sub tInt_Click (Index As Integer)
  734. Dim i&, Y%
  735. For Y% = 0 To 4
  736.    tInt(Y%).Checked = False
  737. tInt(Index).Checked = True
  738. Select Case Index
  739. Case 0
  740.    i& = 1000
  741. Case 1
  742.    i& = 5000
  743. Case 2
  744.    i& = 10000
  745. Case 3
  746.    i& = 30000
  747. Case 4
  748.    i& = 60000
  749. End Select
  750. Timer1.Interval = i&
  751. End Sub
  752.